```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MySQL集群数据同步机制详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #1a1a1a;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            background: linear-gradient(120deg, #f6d365 0%, #fda085 100%);
            background-repeat: no-repeat;
            background-size: 100% 40%;
            background-position: 0 88%;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin-right: 0.1em;
            color: #667eea;
        }
        .timeline-item:before {
            content: '';
            position: absolute;
            left: -40px;
            top: 0;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #667eea;
            border: 4px solid #e2e8f0;
        }
        .timeline-line:before {
            content: '';
            position: absolute;
            left: -31px;
            top: 0;
            height: 100%;
            width: 2px;
            background: #cbd5e0;
        }
        .hover-underline-animation {
            position: relative;
        }
        .hover-underline-animation:after {
            content: '';
            position: absolute;
            width: 100%;
            transform: scaleX(0);
            height: 2px;
            bottom: 0;
            left: 0;
            background-color: #667eea;
            transform-origin: bottom right;
            transition: transform 0.25s ease-out;
        }
        .hover-underline-animation:hover:after {
            transform: scaleX(1);
            transform-origin: bottom left;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl flex flex-col items-center">
            <div class="w-full md:w-4/5 text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">MySQL集群数据同步机制</h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">探索分布式数据库系统的核心技术与实现原理</p>
                <div class="flex justify-center space-x-4">
                    <a href="#architecture" class="px-6 py-3 bg-white text-indigo-700 rounded-lg font-semibold hover:bg-gray-100 transition duration-300">
                        <i class="fas fa-project-diagram mr-2"></i>架构类型
                    </a>
                    <a href="#mechanism" class="px-6 py-3 bg-indigo-800 bg-opacity-50 rounded-lg font-semibold hover:bg-opacity-70 transition duration-300">
                        <i class="fas fa-cogs mr-2"></i>同步原理
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl py-12 px-4 md:px-6">
        <!-- Intro Section -->
        <section class="mb-16">
            <div class="prose max-w-none">
                <p class="drop-cap">在当今数据驱动的时代，数据库的高可用性和一致性是保障系统稳定运行的关键。MySQL作为最受欢迎的开源关系型数据库之一，通过集群技术提供了强大的扩展性和高可用性。集群技术允许我们在多个数据库节点之间分配数据和负载，从而提高系统的性能和可靠性。</p>
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718615515105-83843f99-6747-4e6d-88d8-c53dd23be808.png" alt="MySQL集群示意图" class="w-full rounded-lg shadow-lg my-8">
                <p>随着数据分布在多个节点之间，如何确保各个节点的数据一致性和同步性就成为了一个必须解决的问题。想象一下，如果我们的系统在不同的数据库节点上拥有不同的数据信息，那么这种情况下，数据的不一致将导致业务逻辑的混乱，严重时甚至会影响到整个系统的正常运行。因此，消息同步技术在MySQL集群中扮演着至关重要的角色，它能够确保各个节点之间的数据同步，从而保持数据的一致性。</p>
            </div>
        </section>

        <!-- Architecture Types Section -->
        <section id="architecture" class="mb-16">
            <h2 class="text-3xl font-bold mb-8 pb-2 border-b-2 border-gray-200">MySQL集群的架构类型</h2>
            <p class="text-lg text-gray-700 mb-8">MySQL集群架构类型多种多样，每种架构都有其特定的应用场景和优缺点。</p>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <!-- Master-Slave Card -->
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-indigo-100 p-3 rounded-full mr-4">
                                <i class="fas fa-sitemap text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold">主从复制</h3>
                        </div>
                        <p class="text-gray-600 mb-4">主从复制是一种最常见的MySQL集群架构。在这种架构中，一个数据库节点作为主节点（Master），处理所有的写操作，并生成二进制日志（Binary Log）。多个从节点（Slave）读取主节点的二进制日志，并应用这些日志到自己的数据库中，从而实现数据同步。</p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718615609861-8d456bb5-081d-4298-b621-70eddf4a220a.png" alt="主从复制架构" class="w-full rounded mb-4">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-semibold text-blue-800 mb-2 flex items-center">
                                <i class="fas fa-check-circle mr-2"></i>优势
                            </h4>
                            <ul class="list-disc list-inside text-blue-700 space-y-1">
                                <li>读写分离：主节点处理写操作，从节点处理读操作</li>
                                <li>高可用性：主节点故障时可提升从节点为主节点</li>
                                <li>扩展性：可轻松扩展读操作处理能力</li>
                            </ul>
                        </div>
                        <div class="bg-red-50 p-4 rounded-lg mt-4">
                            <h4 class="font-semibold text-red-800 mb-2 flex items-center">
                                <i class="fas fa-exclamation-triangle mr-2"></i>存在的问题
                            </h4>
                            <ul class="list-disc list-inside text-red-700 space-y-1">
                                <li>数据一致性：可能出现数据不一致</li>
                                <li>复制延迟：从节点应用日志存在延迟</li>
                                <li>单点故障：主节点是单点故障来源</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- Master-Master Card -->
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-exchange-alt text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-2xl font-bold">主主复制</h3>
                        </div>
                        <p class="text-gray-600 mb-4">主主复制是一种双向复制架构，在这种架构中，两个数据库节点互为主从，即每个节点既是主节点也是从节点。两个节点可以同时处理读写操作，并将自己的二进制日志复制到对方节点。</p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718615727564-4ac87fd3-2f5a-4c33-a4c8-7242572f7d08.png" alt="主主复制架构" class="w-full rounded mb-4">
                        <div class="bg-blue-50 p-4 rounded-lg">
                            <h4 class="font-semibold text-blue-800 mb-2 flex items-center">
                                <i class="fas fa-check-circle mr-2"></i>优势
                            </h4>
                            <ul class="list-disc list-inside text-blue-700 space-y-1">
                                <li>高可用性：任意节点故障不影响系统运行</li>
                                <li>负载均衡：读写操作可分布在两个节点上</li>
                            </ul>
                        </div>
                        <div class="bg-red-50 p-4 rounded-lg mt-4">
                            <h4 class="font-semibold text-red-800 mb-2 flex items-center">
                                <i class="fas fa-exclamation-triangle mr-2"></i>存在的问题
                            </h4>
                            <ul class="list-disc list-inside text-red-700 space-y-1">
                                <li>数据冲突：可能产生数据冲突</li>
                                <li>复杂性增加：配置管理相对复杂</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-8">
                <!-- GTID Card -->
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-teal-100 p-3 rounded-full mr-4">
                                <i class="fas fa-fingerprint text-teal-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">GTID复制</h3>
                        </div>
                        <p class="text-gray-600 mb-4">GTID复制基于全局事务标识符，每个事务在主节点上执行时都会生成一个唯一的GTID，从节点通过GTID来确定需要复制和应用的事务，确保数据的一致性。</p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718615827837-152166cd-7733-491e-a198-f892dc10c355.png" alt="GTID复制架构" class="w-full rounded mb-4">
                        <div class="space-y-4">
                            <div class="bg-green-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-green-800 text-sm">优势</h4>
                                <p class="text-green-700 text-sm">简化管理，确保数据一致性</p>
                            </div>
                            <div class="bg-orange-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-orange-800 text-sm">问题</h4>
                                <p class="text-orange-700 text-sm">兼容性问题，性能开销</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Group Replication Card -->
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-pink-100 p-3 rounded-full mr-4">
                                <i class="fas fa-users text-pink-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">Group Replication</h3>
                        </div>
                        <p class="text-gray-600 mb-4">基于Paxos协议的多主复制架构，支持多个节点同时处理读写操作。所有节点组成一个复制组，事务在所有节点之间同步，确保数据一致性。</p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718615910201-66a821b7-2aa9-4799-a138-f7216a338f82.png" alt="Group Replication架构" class="w-full rounded mb-4">
                        <div class="space-y-4">
                            <div class="bg-green-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-green-800 text-sm">优势</h4>
                                <p class="text-green-700 text-sm">强一致性，自动故障恢复，灵活性高</p>
                            </div>
                            <div class="bg-orange-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-orange-800 text-sm">问题</h4>
                                <p class="text-orange-700 text-sm">复杂性增加，性能影响</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- NDB Cluster Card -->
                <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="bg-yellow-100 p-3 rounded-full mr-4">
                                <i class="fas fa-network-wired text-yellow-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">NDB Cluster</h3>
                        </div>
                        <p class="text-gray-600 mb-4">一种真正的分布式数据库架构，支持多主、多从节点，数据分布在多个数据节点上，管理节点负责协调和监控。</p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1718616113156-90592030-a9a7-48e3-be73-a1f21ebe55ae.png" alt="NDB Cluster架构" class="w-full rounded mb-4">
                        <div class="space-y-4">
                            <div class="bg-green-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-green-800 text-sm">优势</h4>
                                <p class="text-green-700 text-sm">高可用性，横向扩展性，实时性强</p>
                            </div>
                            <div class="bg-orange-50 p-3 rounded-lg">
                                <h4 class="font-semibold text-orange-800 text-sm">问题</h4>
                                <p class="text-orange-700 text-sm">配置复杂，资源消耗大</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Synchronization Mechanism Section -->
        <section id="mechanism" class="mb-16">
            <h2 class="text-3xl font-bold mb-8 pb-2 border-b-2 border-gray-200">消息同步的基本原理</h2>
            <p class="text-lg text-gray-700 mb-8">消息同步是MySQL集群中确保数据一致性和高可用性的重要机制。它的基本原理围绕数据的复制和同步展开，涉及多个关键组件和技术。</p>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12">
                <div class="p-6">
                    <h3 class="text-2xl font-bold mb-6 flex items-center">
                        <i class="fas fa-file-alt text-blue-500 mr-3"></i>MySQL复制的基本概念
                    </h3>

                    <div class="grid md:grid-cols-2 gap-8">
                        <!-- Binary Log -->
                        <div class="bg-gray-50 p-5 rounded-lg">
                            <div class="flex items-center mb-3">
                                <div class="bg-blue-100 p-2 rounded-full mr-3">
                                    <i class="fas fa-file-code text-blue-600"></i>
                                </div>
                                <h4 class="text-xl font-semibold">二进制日志</h4>
                            </div>
                            <p class="text-gray-700">二进制日志是MySQL实现数据复制的核心。主节点将所有对数据库进行修改的操作记录到二进制日志中，不仅用于数据恢复，还用于从节点的数据同步。</p>
                            <div class="mt-4">
                                <div class="flex items-start mb-2">
                                    <div class="flex-shrink-0 text-blue-500 mr-2">•</div>
                                    <span class="text-sm text-gray-600"><strong>格式：</strong>基于语句(SBR)、基于行(RBR)及混合模式(MBR)</span>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 text-blue-500 mr-2">•</div>
                                    <span class="text-sm text-gray-600"><strong>作用：</strong>记录事务的完整执行过程，确保从节点能重现所有数据变更</span>
                                </div>
                            </div>
                        </div>

                        <!-- Relay Log -->
                        <div class="bg-gray-50 p-5 rounded-lg">
                            <div class="flex items-center mb-3">
                                <div class="bg-purple-100 p-2 rounded-full mr-3">
                                    <i class="fas fa-exchange-alt text-purple-600"></i>
                                </div>
                                <h4 class="text-xl font-semibold">中继日志</h4>
                            </div>
                            <p class="text-gray-700">中继日志只在主从服务器架构的从服务器上存在。从服务器从主服务器读取二进制日志，写入本地中继日志，然后读取中继日志更新数据，起到中介作用。</p>
                            <div class="mt-4">
                                <div class="flex items-start mb-2">
                                    <div class="flex-shrink-0 text-purple-500 mr-2">•</div>
                                    <span class="text-sm text-gray-600"><strong>格式：</strong>与二进制日志相同</span>
                                </div>
                                <div class="flex items-start">
                                    <div class="flex-shrink-0 text-purple-500 mr-2">•</div>
                                    <span class="text-sm text-gray-600"><strong>作用：</strong>充当数据同步的中转站，确保数据完整性和一致性</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="mt-8 grid md:grid-cols-2 gap-8">
                        <!-- IO Thread -->
                        <div class="bg-indigo-50 p-5 rounded-lg">
                            <div class="flex items-center mb-3">
                                <div class="bg-indigo-100 p-2 rounded-full mr-3">
                                    <i class="fas fa-download text-indigo-600"></i>
                                </div>
                                <h4 class="text-xl font-semibold">I/O线程</h4>
                            </div>
                            <p class="text-gray-700">从节点上的I/O线程负责连接主节点，读取二进制日志，并将其写入本地的中继日志中。I/O线程会不断地轮询主节点的二进制日志文件，以获取最新的变更。</p>
                        </div>

                        <!-- SQL Thread -->
                        <div class="bg-teal-50 p-5 rounded-lg">
                            <div class="flex items-center mb-3">
                                <div class="bg-teal-100 p-2 rounded-full mr-3">
                                    <i class="fas fa-database text-teal-600"></i>
                                </div>
                                <h4 class="text-xl font-semibold">SQL线程</h4>
                            </div>
                            <p class="text-gray-700">从节点上的SQL线程负责读取中继日志中的内容，并将这些操作应用到从节点的数据库中。通过这种方式，从节点的数据与主节点的数据保持同步。</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Replication Process -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-project-diagram text-green-500 mr-3"></i>数据复制的基本流程
                </h3>

                <div class="relative">
                    <!-- Timeline line -->
                    <div class="absolute left-0 top-0 h-full w-0.5 bg-gray-200 ml-4 md:ml-0 md:left-1/2 md:-ml-1"></div>

                    <!-- Timeline items -->
                    <div class="space-y-8">
                        <!-- Step 1 -->
                        <div class="relative pl-10 md:pl-0 md:flex md:odd:flex-row-reverse">
                            <div class="md:w-1/2 md:px-8">
                                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                                    <div class="flex items-center mb-2">
                                        <div class="bg-green-100 text-green-800 rounded-full w-8 h-8 flex items-center justify-center mr-3 font-bold">1</div>
                                        <h4 class="text-lg font-semibold">主节点生成二进制日志</h4>
                                    </div>
                                    <p class="text-gray-600">当主节点上的数据发生变更时，所有的写操作（事务）都会被记录到二进制日志中。这些日志记录了每个事务的执行细节，包括时间戳、事务ID、具体的SQL操作等。</p>
                                </div>
                            </div>
                            <div class="md:w-1/2"></div>
                        </div>

                        <!-- Step 2 -->
                        <div class="relative pl-10 md:pl-0 md:flex">
                            <div class="md:w-1/2"></div>
                            <div class="md:w-1/2 md:px-8">
                                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                                    <div class="flex items-center mb-2">
                                        <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center mr-3 font-bold">2</div>
                                        <h4 class="text-lg font-semibold">从节点读取中继日志</h4>
                                    </div>
                                    <p class="text-gray-600">从节点的I/O线程连接到主节点，读取主节点的二进制日志，并将其写入本地的中继日志中。I/O线程会不断地轮询主节点的二进制日志文件，以获取最新的变更。</p>
                                </div>
                            </div>
                        </div>

                        <!-- Step 3 -->
                        <div class="relative pl-10 md:pl-0 md:flex md:odd:flex-row-reverse">
                            <div class="md:w-1/2 md:px-8">
                                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                                    <div class="flex items-center mb-2">
                                        <div class="bg-purple-100 text-purple-800 rounded-full w-8 h-8 flex items-center justify-center mr-3 font-bold">3</div>
                                        <h4 class="text-lg font-semibold">从节点应用中继日志</h4>
                                    </div>
                                    <p class="text-gray-600">从节点的SQL线程负责读取中继日志中的操作，并按照记录的顺序在从节点的数据库中重放这些操作。通过这种方式，从节点的数据与主节点的数据保持同步。</p>
                                </div>
                            </div>
                            <div class="md:w-1/2"></div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Replication Modes -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-sliders-h text-orange-500 mr-3"></i>主从复制的实现细节
                </h3>

                <div class="grid md:grid-cols-3 gap-6">
                    <!-- Async Replication -->
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-gray-100 p-2 rounded-full mr-3">
                                <i class="fas fa-clock text-gray-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold">异步复制</h4>
                        </div>
                        <p class="text-gray-600 mb-3">MySQL默认使用异步复制，即主节点在写操作完成后立即返回，不等待从节点确认。</p>
                        <div class="bg-gray-50 p-3 rounded">
                            <p class="text-sm font-semibold text-gray-700 mb-1">特点</p>
                            <ul class="text-sm text-gray-600 space-y-1">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-gray-500 mr-2">✓</div>
                                    <span>写操作性能高</span>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-gray-500 mr-2">✗</div>
                                    <span>可能出现数据不一致</span>
                                </li>
                            </ul>
                        </div>
                    </div>

                    <!-- Semi-Sync Replication -->
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-blue-100 p-2 rounded-full mr-3">
                                <i class="fas fa-hourglass-half text-blue-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold">半同步复制</h4>
                        </div>
                        <p class="text-gray-600 mb-3">主节点在写操作完成后，会等待至少一个从节点确认已接收到并写入二进制日志后，再返回确认给客户端。</p>
                        <div class="bg-blue-50 p-3 rounded">
                            <p class="text-sm font-semibold text-blue-700 mb-1">特点</p>
                            <ul class="text-sm text-blue-600 space-y-1">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-blue-500 mr-2">✓</div>
                                    <span>减少数据丢失风险</span>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-blue-500 mr-2">⚠</div>
                                    <span>性能介于异步和全同步之间</span>
                                </li>
                            </ul>
                        </div>
                    </div>

                    <!-- Full Sync Replication -->
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
                        <div class="flex items-center mb-4">
                            <div class="bg-red-100 p-2 rounded-full mr-3">
                                <i class="fas fa-check-double text-red-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold">全同步复制</h4>
                        </div>
                        <p class="text-gray-600 mb-3">主节点在所有从节点确认已接收到并写入二进制日志后，才返回确认给客户端。</p>
                        <div class="bg-red-50 p-3 rounded">
                            <p class="text-sm font-semibold text-red-700 mb-1">特点</p>
                            <ul class="text-sm text-red-600 space-y-1">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-red-500 mr-2">✓</div>
                                    <span>确保数据一致性</span>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 text-red-500 mr-2">✗</div>
                                    <span>对性能影响较大</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- GTID Replication -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-id-card text-teal-500 mr-3"></i>GTID复制机制
                </h3>

                <div class="bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="flex flex-col md:flex-row">
                            <div class="md:w-1/2 md:pr-6">
                                <h4 class="text-xl font-semibold mb-4">GTID (Global Transaction Identifier)</h4>
                                <p class="text-gray-600 mb-4">GTID是MySQL 5.6引入的一种全局事务标识符，用于唯一标识每个事务。每个事务在执行时都会生成一个唯一的GTID，主节点和从节点通过GTID来跟踪和同步事务。</p>
                                
                                <div class="bg-teal-50 p-4 rounded-lg mb-6">
                                    <h5 class="font-semibold text-teal-800 mb-2 flex items-center">
                                        <i class="fas fa-star mr-2"></i>GTID的优势
                                    </h5>
                                    <ul class="list-disc list-inside text-teal-700 space-y-1">
                                        <li>简化管理：简化了主从切换和故障恢复过程</li>
                                        <li>确保一致性：准确跟踪和应用每个事务</li>
                                    </ul>
                                </div>
                            </div>
                            <div class="md:w-1/2">
                                <div class="mermaid">
                                    graph LR
                                    A[主节点: 事务T1] -->|生成GTID| B(服务器UUID:1)
                                    B --> C[二进制日志]
                                    C --> D[从节点I/O线程]
                                    D --> E[中继日志]
                                    E --> F[从节点SQL线程]
                                    F --> G[应用事务T1]
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Summary Diagram -->
            <div class="bg-white p-6 rounded-xl shadow-md mb-12">
                <h3 class="text-2xl font-bold mb-6">主从复制过程总结</h3>
                <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1661267799619-29dd040a-8b4d-4891-b4c4-a93d5ac29aa5.png?x-oss-process=image%2Fresize%2Cw_706%2Climit_0" alt="主从复制过程示意图" class="w-full rounded-lg mb-6">
                
                <div class="bg-yellow-50 p-4 rounded-lg border border-yellow-200">
                    <h4 class="font-semibold text-yellow-800 mb-3 flex items-center">
                        <i class="fas fa-lightbulb mr-2"></i>关键要点
                    </h4>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <div class="flex-shrink-0 text-yellow-500 mr-2">•</div>
                            <span>master将操作语句记录到binlog日志中，授予slave远程连接权限</span>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 text-yellow-500 mr-2">•</div>
                            <span>slave开启IO线程和SQL线程：IO线程读取binlog到relay log，SQL线程从relay log读取并更新数据库</span>
                        </li>
                        <li class="flex items-start">
                            <div class="flex-shrink-0 text-yellow-500 mr-2">•</div>
                            <span>至少需要两个MySQL服务，版本需兼容，时间需同步</span>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- Replication Types -->
            <div>
                <h3 class="text-2xl font-bold mb-6">MySQL支持的复制类型</h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <div class="flex items-center mb-3">
                            <div class="bg-blue-100 p-2 rounded-full mr-3">
                                <i class="fas fa-align-left text-blue-600"></i>
                            </div>
                            <h4 class="text-lg font-semibold">基于语句的复制</h4>
                        </div>
                        <p class="text-gray-600">在主服务器上执行的SQL语句，在从服务器上执行同样的语句。MySQL默认采用基于语句的复制，效率较高。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <div class="flex items-center mb-3">
                            <div class="bg-green-100 p-2 rounded-full mr-3">
                                <i class="fas fa-table text-green-600"></i>
                            </div>
                            <h4 class="text-lg font-semibold">基于行的复制</h3>
                        </div>
                        <p class="text-gray-600">把改变的内容复制过去，而不是把命令在从服务器上执行一遍。从MySQL 5.0开始支持。</p>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <div class="flex items-center mb-3">
                            <div class="bg-purple-100 p-2 rounded-full mr-3">
                                <i class="fas fa-random text-purple-600"></i>
                            </div>
                            <h4 class="text-lg font-semibold">混合类型的复制</h4>
                        </div>
                        <p class="text-gray-600">默认采用基于语句的复制，一旦发现基于语句的无法精确复制时，就会采用基于行的复制。</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold hover-underline-animation inline-block">技术小馆</h3>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300 hover-underline-animation">
                        <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```